<template>
  <basic-container>
    <div>
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane v-for="item  in moduleList" :key="item.value" :label="item.name" :name="item.value">

        </el-tab-pane>
      </el-tabs>
      <div>
        <DetailCard :recordlist="recordlist" :activeName="activeName" :noticeId="noticeId" @fatherMethod="fatherMethod" />
      </div>
    </div>
  </basic-container>
</template>

<script>
import { getModule } from '@/api/archives/module';
import DetailCard from './components/detailCard.vue'
import { list } from '@/api/archives/notice'
export default {
  name: 'Detail',
  components: {
    DetailCard
  },
  data() {
    return {
      activeName: 'first',
      moduleList: [],
      recordlist: {},
      noticeId: null,
      dictId: '',
    }
  },
  created() {
    this.getModuleList()
    this.getList()

  },
  methods: {
    fatherMethod() {
      this.getList()
    },
    getList() {
      list({
        pageNum: 1,
        pageSize: 10,
        dictId: this.dictId,
        archivesId: this.$route.query.archivesId
      }).then(res => {
        this.recordlist = res.rows[0]
      })
    },
    getModuleList() {
      getModule(this.$route.query.archivesId).then(res => {
        this.moduleList = res.data
        this.activeName = res?.data[0].value
        this.noticeId = this.moduleList[0].noticeId
        this.dictId = this.moduleList[0].value
      })
    },
    handleClick(e) {
      this.dictId = e.name
      list({
        pageNum: 1,
        pageSize: 10,
        dictId: e.name,
        archivesId: this.$route.query.archivesId
      }).then(res => {
        this.recordlist = res.rows[0]
      })
      this.noticeId = this.moduleList[e.index].noticeId
    },
    tabPaneClick(e) {
      console.log(e)
    },
  }
}
</script>

<style lang="scss" scoped>
</style>